package com.project_doctor.mapper;

import com.project_doctor.pojo.Doctor;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project_doctor.pojo.dto.DoctorRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author xixif
* @description 针对表【t_doctor(医生信息表)】的数据库操作Mapper
* @createDate 2025-06-16 15:44:19
* @Entity com.project_doctor.pojo.Doctor
*/
public interface DoctorMapper extends BaseMapper<Doctor> {
    List<Doctor> getAllDoctorsWithRoleAndTeam(DoctorRequest doctorRequest);

    @Select(" <script>" +
            " SELECT d.*, t.id as team_id, t.name AS team_name, r.id as role_id, r.name " +
            " FROM t_team t " +
            " INNER JOIN t_doctor d ON d.team_id = t.id " +
            " INNER JOIN t_role r ON d.id = r.id " +
            " WHERE d.id IN " +
            " <foreach item='id' collection='ids' open='(' separator=',' close=')'>" +
            " #{id}" +
            " </foreach>" +
            " </script>")
    @Results({
            @Result(property = "id", column = "id"), // 主键映射（如果 Doctor 有 @Id 可省略）
            @Result(property = "team.id", column = "team_id"),
            @Result(property = "team.teamName", column = "team_name"),
            @Result(property = "role.id", column = "role_id"),
            @Result(property = "role.roleName", column = "role_name")
    })
    List<Doctor> getDoctorByBatchId(@Param("ids") List<Long> ids);
}




